package com.qf.work01.utils;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class MybatisUtils {

    public static SqlSession m1() throws IOException {
        InputStream is = Resources.getResourceAsStream("mybatis-config.xml");

        //创建一个 SqlSessionFactoryBuilder对象
        SqlSessionFactoryBuilder ssfb = new SqlSessionFactoryBuilder();
        //利用SqlSessionFactory 对象可以创建 Sqlsession对象
        SqlSessionFactory build = ssfb.build(is);
        SqlSession sqlSession = build.openSession();
        return sqlSession;
    }
}
